import fetch from 'utils/fetch';
import Cookies from 'js-cookie';

// 查产品列表
export function getList(requestParams) {
  const operatorid = Cookies.get('uid');
  const lastlogincode = Cookies.get('lastlogincode')
  Object.assign(requestParams, { operatorid, lastlogincode });
  return fetch({
    url: '/trc-service-product/production/queryTraceArchivesForReportStatistics',
    method: 'post',
    data: JSON.stringify(requestParams),
    headers: {
      'Content-Type': 'application/json'
    }
  });
}

// 指定时间查询报表数据
// 今日报表统计（包含：浏览量、企业入驻数、新增追溯档案数、新增防伪档案数）
export function getReportDataByDate(requestParams) {
  const operatorid = Cookies.get('uid');
  const lastlogincode = Cookies.get('lastlogincode')
  Object.assign(requestParams, { operatorid, lastlogincode });
  return fetch({
    url: '/trc-service-report/report/staticLatestTwoDaysTime',
    method: 'post',
    data: JSON.stringify(requestParams),
    headers: {
      'Content-Type': 'application/json'
    }
  });
}

// 指定时间段查询报表数据
// type (1:浏览量统计,2:企业入驻统计,3:追溯档案统计,4:防伪档案统计)
// day(7,30,90,180)
export function getReportDataByDateScope(requestParams) {
  const operatorid = Cookies.get('uid');
  const lastlogincode = Cookies.get('lastlogincode')
  Object.assign(requestParams, { operatorid, lastlogincode });
  return fetch({
    url: '/trc-service-report/report/queryVisitCount',
    method: 'post',
    data: JSON.stringify(requestParams),
    headers: {
      'Content-Type': 'application/json'
    }
  });
}